//
//  customModal.m
//  car
//
//  Created by chenxu on 3/30/15.
//  Copyright (c) 2015 chenxu. All rights reserved.
//

#import "customModal.h"
#import "PresentingAnimator.h"
#import "DismissingAnimator.h"
@implementation customModal

- (void)perform

{
    
    UIViewController *current = self.sourceViewController;
    
    UIViewController *next = self.destinationViewController;
    next.transitioningDelegate = self;
    next.modalPresentationStyle = UIModalPresentationCustom;
    
    [current.navigationController presentViewController:next
                                            animated:YES
                                          completion:NULL];
   // [current.navigationController pushViewController:next animated:YES];
    
    
}

#pragma mark - UIViewControllerTransitioningDelegate

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
                                                                  presentingController:(UIViewController *)presenting
                                                                      sourceController:(UIViewController *)source
{
    return [PresentingAnimator new];
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    return [DismissingAnimator new];
}
@end

@implementation customModaldismiss

- (void)perform

{
    
    UIViewController *current = self.sourceViewController;
    
    UIViewController *next = self.destinationViewController;
    next.transitioningDelegate = self;
    next.modalPresentationStyle = UIModalPresentationCustom;
    
    [current.navigationController presentViewController:next
                                               animated:YES
                                             completion:NULL];
    // [current.navigationController pushViewController:next animated:YES];
    
    
}

#pragma mark - UIViewControllerTransitioningDelegate

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
                                                                  presentingController:(UIViewController *)presenting
                                                                      sourceController:(UIViewController *)source
{
    return [PresentingAnimator new];
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    return [DismissingAnimator new];
}
@end
